// 通用类型定义

// API 响应基础接口
export interface ApiResponse<T = any> {
  code: number;
  data: T;
  message: string;
}

// 分页接口
export interface Pagination {
  page: number;
  pageSize: number;
  total: number;
}

// 分页响应接口
export interface PaginationResponse<T = any> {
  list: T[];
  total: number;
}

// 表格列配置
export interface TableColumn {
  prop: string;
  label: string;
  width?: number | string;
  minWidth?: number | string;
  fixed?: boolean | "left" | "right";
  sortable?: boolean;
  align?: "left" | "center" | "right";
}

// 表单项配置
export interface FormItem {
  field: string;
  label: string;
  type: "input" | "select" | "date" | "textarea" | "number";
  required?: boolean;
  placeholder?: string;
  options?: Array<{ label: string; value: any }>;
}

// 菜单项接口
export interface MenuItem {
  id: string;
  title: string;
  icon?: string;
  path?: string;
  children?: MenuItem[];
}

// 用户权限
export type Permission = "read" | "write" | "delete" | "admin";

// 主题配置
export interface ThemeConfig {
  primaryColor: string;
  isDark: boolean;
  layout: "vertical" | "horizontal";
}

// 路由元信息
export interface RouteMeta {
  title: string;
  icon?: string;
  requireAuth?: boolean;
  permissions?: Permission[];
  keepAlive?: boolean;
}

// 文件上传接口
export interface UploadFile {
  name: string;
  url: string;
  size: number;
  type: string;
}

// 状态枚举
export enum StatusEnum {
  PENDING = "pending",
  SUCCESS = "success",
  ERROR = "error",
  LOADING = "loading",
}

// 请求方法枚举
export enum HttpMethod {
  GET = "GET",
  POST = "POST",
  PUT = "PUT",
  DELETE = "DELETE",
  PATCH = "PATCH",
}

// 通用 ID 类型
export type ID = string | number;

// 可选属性工具类型
export type Optional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;

// 必需属性工具类型
export type Required<T, K extends keyof T> = T & { [P in K]-?: T[P] };
